package architecture.dbinterface;

import java.util.*;

public class DummyDatabase extends DatabaseInterface {

	private String[] groups = new String[]{"administrator","seller", "buyer", "guest"};
	private HashMap<String, String> userPasswords = new HashMap<String, String>();
		
	private Random rand = new Random();
	
	public String[] getAllTables() {
		return new String[]{"Tabela1","Tabela2","Tabela3"};
	}

	public Vector<String> getRestrictionsForUser(String user) {
		return new Vector<String>();
	}
	
	public Vector<String> getRightsForGroup(String group) {
		Vector<String> rights = new Vector<String>();
		
		if (group.equals(groups[0]))
		{
			 rights.add("MENU_TABLES");
		}
		if (group.equals(groups[1]))
		{
			 //ights.add("MENU_TABLES");	
		}
		if (group.equals(groups[2]))
		{
			rights.add("MENU_BASKET");
		}
		return rights;
	}

	@Override
	public String getGroupForUser(String user) {
		if (user.equals("guest"))
			return groups[3];
		return groups[rand.nextInt(groups.length-1)];
	}

	@Override
	public String getPassForUser(String username)
	{
		userPasswords.put("kabiljo", "jew");
		userPasswords.put("dule", "babojebac");
		userPasswords.put("janko", "ucha");
		userPasswords.put("steva", "b92crnac");
		
		if (userPasswords.containsKey(username))
			return userPasswords.get(username);
		else return "";
	}
	
	@Override
	public void disconnect() {
		return;		
	}
}
